<template>
  <div class="work-notice">
    <div class="module-title">
      <div class="title-left">
        <img src="@images/home/work-notice.png" alt="" />
        <span>工作通知</span>
      </div>
      <div class="title-right" @click="goMorepage">
        更多
        <i class="el-icon-arrow-right"></i>
      </div>
    </div>
    <div class="module-con" v-if="list.length">
      <div class="con-item" v-for="(item, index) in list" :key="index" @click="goDetailpage(item)">
        <div class="item-left">
          <span v-if="item.isTop == 1">[置顶]</span>
          {{ item.bulletinTitle }}
        </div>
        <div class="item-right">{{ item.releaseTime }}</div>
      </div>
    </div>
    <Empty v-else class="empty-box"></Empty>
  </div>
</template>

<script>
import Empty from '@com/Empty.vue'
import { selectAllBulletin } from '@apis/notice.js'
export default {
  name: 'WorkNotice',
  components: {
    Empty,
  },
  emits: [],
  props: {},
  data() {
    return {
      selectParams: {
        pageNum: 1,
        pageSize: 5,
        searchContent: '',
        status: '1',
        type: '0', // 类型：0为工作通知 1为制度文件
        userType: 2, // 1:管理员查看所有；2：普通用户登录-查看自己能看到的
      },
      list: [],
    }
  },
  created() {
    this.initdata()
  },
  mounted() {},
  methods: {
    /* 初始化数据 */
    initdata() {
      selectAllBulletin({
        ...this.selectParams,
      }).then(res => {
        const data = res.data
        this.list = data.content
      })
    },
    goMorepage() {
      this.$router.push({
        path: '/examine/file/gztz',
      })
    },
    goDetailpage(item) {
      this.$router.push({
        name: 'PSKH_SYSTEM_FILE_DETAIL',
        params: { id: item.bulletionId, type: this.selectParams.item },
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.work-notice {
  height: 100%;
  padding: 0 20px;
  .module-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .title-left {
      display: flex;
      align-items: center;
      span {
        font-size: 18px;
        font-weight: bold;
        margin-left: 9px;
      }
    }
    .title-right {
      font-size: 14px;
      cursor: pointer;
    }
  }
  .module-con {
    margin-top: 15px;
    .con-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px dashed #eeeeee;
      line-height: 24px;
      font-size: 14px;
      padding: 5px 0;
      cursor: pointer;
      span {
        color: #0060c4;
      }
      .item-right {
        color: #777777;
        margin-left: 5px;
        min-width: 80px;
        text-align: right;
      }
      .item-left {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
    }
  }
}
</style>
